package com.block.common.enums;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.netty.buffer.PoolSubpageMetric;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseTypeInfoEnum {

    public static void main(String[] args) {

        System.out.println(JSON.toJSONString(ZhimaScore.getDataMap()));
    }

    public static JSONObject resultData = new JSONObject();

    public static List<BaseTypeInfo> multDataList = new ArrayList<>();
    public static List<BaseTypeInfo> singleDataList = new ArrayList<>();

    static {

        multDataList.add(
                BaseTypeInfo.build(LoanAmount.baseName, LoanAmount.baseValue, LoanAmount.getDataMap())
        );

        multDataList.add(
                BaseTypeInfo.build(LoanTime.baseName, LoanTime.baseValue, LoanTime.getDataMap())
        );

        multDataList.add(
                BaseTypeInfo.build(ZhimaScore.baseName, ZhimaScore.baseValue, ZhimaScore.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Gjj.baseName, Gjj.baseValue, Gjj.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Salary.baseName, Salary.baseValue, Salary.getDataMap())
        );



        multDataList.add(
                BaseTypeInfo.build(House.baseName, House.baseValue, House.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Job.baseName, Job.baseValue, Job.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Car.baseName, Car.baseValue, Car.getDataMap())
        );
        // 学历
        multDataList.add(
                BaseTypeInfo.build(XueLi.baseName, XueLi.baseValue, XueLi.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(Purpose.baseName, Purpose.baseValue, Purpose.getDataMap())
        );
        // 有无逾期
        multDataList.add(
                BaseTypeInfo.build(Yuqi.baseName, Yuqi.baseValue, Yuqi.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(EnterpriseOwner.baseName, EnterpriseOwner.baseValue, EnterpriseOwner.getDataMap())
        );



        multDataList.add(
                BaseTypeInfo.build(SheBao.baseName, SheBao.baseValue, SheBao.getDataMap())
        );
        multDataList.add(
                BaseTypeInfo.build(BaoDan.baseName, BaoDan.baseValue, BaoDan.getDataMap())
        );

//        multDataList.add(
//                BaseTypeInfo.build(Baitiao.baseName, Baitiao.baseValue, Baitiao.getDataMap())
//        );
//        multDataList.add(
//                BaseTypeInfo.build(Huabei.baseName, Huabei.baseValue, Huabei.getDataMap())
//        );

        resultData.put("multDataList", multDataList);
//        resultData.put("singleDataList", singleDataList);

    }


    @Data
    public static class BaseTypeInfo{
        private  String name;
        private  String value;
        private  List<Map<String, String>> itemList;

        public static BaseTypeInfo build(String name, String value, List<Map<String, String>> itemList){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            baseTypeInfo.setItemList(itemList);
            return baseTypeInfo;
        }

        public static BaseTypeInfo build(String name, String value){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            return baseTypeInfo;
        }
    }

    @Getter
    public enum LoanTime{

        lt001( "0-6个月", "lt001"),
        lt002( "6-12个月", "lt002"),
        lt003( "12个月以上", "lt003"),
        ;

        public static String baseName = "贷款时间";
        public static String baseValue = "loanTime";

        String value;
        String name;

        LoanTime(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (LoanTime loanTime: values()){
                if (StrUtil.equals(value, loanTime.getValue())){
                    return loanTime.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanTime item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum LoanAmount{

        la001( "1-5万", "la001"),
        la002( "5-10万", "la002"),
        la003( "10万以上", "la003"),
//        la004( "20万及以上", "la004", new BigDecimal("250000")),
        ;

        public static String baseName = "贷款额度";
        public static String baseValue = "loanAmount";

        String value;
        String name;
        BigDecimal amount;

        LoanAmount(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount.getName();
                }
            }
            return null;
        }

        public static LoanAmount getEntryByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount;
                }
            }
            return la001;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanAmount item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum ZhimaScore{

        zm001( "无芝麻分", "zm001"),
        zm002( "1-599分", "zm002"),
        zm003( "600-649分", "zm003"),
        zm004( "650-699分", "zm004"),
        zm005( "700分以上", "zm005"),
        ;

        public static String baseName = "芝麻分数";
        public static String baseValue = "zhimaScore";

        String value;
        String name;


        ZhimaScore(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (ZhimaScore zhimaScore: values()){
                if (StrUtil.equals(value, zhimaScore.getValue())){
                    return zhimaScore.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (ZhimaScore item: values()){

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }


    @Getter
    public enum Gjj{

        gjj001("无公积金", "gjj001"),
        gjj002("0-6个月", "gjj002"),
        gjj003("6-12个月", "gjj003"),
        gjj004("12个月及以上", "gjj004"),
        ;

        public static String baseName = "公积金";
        public static String baseValue = "gjj";

        String value;
        String name;


        Gjj(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Gjj gjj: values()){
                if (StrUtil.equals(value, gjj.getValue())){
                    return gjj.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Gjj item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }


    @Getter
    public enum Salary{

        sl001("1500-5000", "sa001"),
        sl002("5000-1万", "sa002"),
        sl003("1万-5万", "sa003"),
        sl004("5万-10万", "sa004"),
        sl005("10万-20万", "sa005"),
        sl006("20万以上", "sa006"),
        ;

        public static String baseName = "薪资";
        public static String baseValue = "salary";

        String value;
        String name;

        Salary(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Salary salary: values()){
                if (StrUtil.equals(value, salary.getValue())){
                    return salary.getName();
                }
            }
            return null;
        }

        public static Salary getEntryByValue(String value){
            for (Salary item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return sl003;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Salary item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }



    @Getter
    public enum House{

        hu001( "无房", "hu001"),
        hu002( "按揭房", "hu002"),
        hu003( "全款房", "hu003"),
        ;

        public static String baseName = "房产情况";
        public static String baseValue = "house";

        String value;
        String name;
        

        House(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (House house: values()){
                if (StrUtil.equals(value, house.getValue())){
                    return house.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (House item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Purpose{

        pu001("购房", "pu001"),
        pu002("结婚", "pu002"),
        pu003("消费", "pu003"),
        pu004("教育培训", "pu004"),
        pu005( "购车", "pu005"),
        pu006( "装修", "pu006"),
        ;

        public static String baseName = "用途";
        public static String baseValue = "purpose";

        String value;
        String name;

        Purpose(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static Purpose getEntryByValue(String value){
            for (Purpose item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return pu003;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Purpose item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum Job{

        job001("上班族", "job001", "vo001"),
        job002("企业主", "job002", "vo002"),
        job003("自由职业", "job003", "vo003"),
        job004("其他", "job004", "vo004"),
        ;

        public static String baseName = "工作";
        public static String baseValue = "job";

        String extValue;
        String value;
        String name;


        Job(String name, String value, String extValue){
            this.value = value;
            this.name = name;
            this.extValue = extValue;
        }

        public static String getNameByValue(String value){
            for (Job job: values()){
                if (StrUtil.equals(value, job.getValue())){
                    return job.getName();
                }
            }
            return null;
        }

        public static Job getEntryByValue(String value){
            for (Job item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return job004;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Job item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Car{

        car001("无车", "car001"),
        car002("按揭车", "car002"),
        car003("全款车", "car003"),
        ;

        public static String baseName = "有车";
        public static String baseValue = "car";

        String value;
        String name;
        

        Car(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Car car: values()){
                if (StrUtil.equals(value, car.getValue())){
                    return car.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Car item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum Yuqi{

        yq001("无逾期", "yq001"),
        yq002("0-6个月逾期", "yq002"),
        yq003("6-12个月逾期", "yq003"),
        yq004("12个月以上逾期", "yq004"),
        ;

        public static String baseName = "逾期情况";
        public static String baseValue = "yuqi";

        String value;
        String name;


        Yuqi(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Yuqi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Yuqi item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum EnterpriseOwner{

        eo001( "非企业主", "eo001"),
        eo002( "是企业主", "eo002"),
        ;

        public static String baseName = "是企业主";
        public static String baseValue = "enterpriseOwner";

        String value;
        String name;


        EnterpriseOwner(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (EnterpriseOwner item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (EnterpriseOwner item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum XueLi{

        xl001("无", "xl001", true),
        xl002("中专及以下", "xl002", true),
        xl003("大专", "xl003", true),
        xl004("本科", "xl004", true),
        xl005("研究生及以上", "xl005", true),
        ;

        String value;
        String name;
        boolean showFlag;

        public static String baseName = "学历";
        public static String baseValue = "xueli";

        XueLi(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static XueLi getEntryByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return xl002;
        }

        public static String getNameByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (XueLi item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum SheBao{

        sb001("无社保", "sb001"),
        sb002("0-6个月", "sb002"),
        sb003("6-12个月", "sb003"),
        sb004("12个月及以上", "sb004"),
        ;

        public static String baseName = "社保";
        public static String baseValue = "shebao";

        String value;
        String name;

        SheBao(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (SheBao item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (SheBao item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum BaoDan{

        bd001("无保单", "bd001"),
        bd002("0-6个月", "bd002"),
        bd003("6-12个月", "bd003"),
        bd004("12个月及以上", "bd004"),
        ;

        public static String baseName = "保单";
        public static String baseValue = "baodan";

        String value;
        String name;

        BaoDan(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (BaoDan item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (BaoDan item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Huabei{

        hb001( "无", "hb001", true),
        hb002( "1-3万", "hb002", true),
        hb003( "3万-5万", "hb003", true),
        hb004( "5万以上", "hb004", true),
        ;

        public static String baseName = "支付宝花呗";
        public static String baseValue = "huabei";

        String value;
        String name;
        boolean showFlag;

        Huabei(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Huabei item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Huabei item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Baitiao{

        bt001( "无", "bt001",true),
        bt002( "1-3万", "bt002", true),
        bt003( "3万-5万", "bt003", true),
        bt004( "5万以上", "bt004", true),
        ;

        public static String baseName = "京东白条";
        public static String baseValue = "baitiao";

        String value;
        String name;
        boolean showFlag;

        Baitiao(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Baitiao item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Baitiao item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


}
